package com.quantoeugasto;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.StringTokenizer;

public class BackupManager {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		File file = new File("C:/SQL.txt");
		try {
			FileReader reader = new FileReader(file);
			BufferedReader br = new BufferedReader(reader);
			while (br.ready()) {
				String line = br.readLine();
				StringTokenizer tokenizer = new StringTokenizer(line, "\t");
				
				System.out.print("INSERT INTO gasto (id, data, descricao, mes, valor, ano_id, categoria_id, primeiraparcela_id) VALUES (");
				
				int cont = 1;
				while (tokenizer.hasMoreTokens()) {
					if (cont == 2 || cont == 3) {
						System.out.print("'");
					}
					
					String valor = tokenizer.nextToken();
					
					if (valor.equals("\\N")) {
						System.out.print("null");
					}
					else {
						System.out.print(valor);
					}
					

					if (cont == 2 || cont == 3) {
						System.out.print("'");
					}
					
					if (tokenizer.hasMoreTokens()) {
						System.out.print(",");
					}
					
					cont++;
				}
				System.out.print(");\n");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}